package cn.edu.nwsuaf.examcenter.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * ExerciceItem entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "exercice_item", catalog = "exam")
public class ExerciceItem implements java.io.Serializable {

	// Fields

	private String itemNo;
	private Cource cource;
	private ExamItemType examItemType;
	private String itemDescription;
	private String itemContent;
	private String itemAnswer;
	private String itemAnalysis;
	private Integer itemLevel;
	private Set<StudentExerciceRecord> studentExerciceRecords = new HashSet<StudentExerciceRecord>(
			0);
	private Set<ExerciceExam> exerciceExams = new HashSet<ExerciceExam>(0);
	private Set<StudentItemExercice> studentItemExercices = new HashSet<StudentItemExercice>(
			0);

	// Constructors

	/** default constructor */
	public ExerciceItem() {
	}

	/** minimal constructor */
	public ExerciceItem(String itemNo, Cource cource,
			ExamItemType examItemType, Integer itemLevel) {
		this.itemNo = itemNo;
		this.cource = cource;
		this.examItemType = examItemType;
		this.itemLevel = itemLevel;
	}

	/** full constructor */
	public ExerciceItem(String itemNo, Cource cource,
			ExamItemType examItemType, String itemDescription,
			String itemContent, String itemAnswer, String itemAnalysis,
			Integer itemLevel,
			Set<StudentExerciceRecord> studentExerciceRecords,
			Set<ExerciceExam> exerciceExams,
			Set<StudentItemExercice> studentItemExercices) {
		this.itemNo = itemNo;
		this.cource = cource;
		this.examItemType = examItemType;
		this.itemDescription = itemDescription;
		this.itemContent = itemContent;
		this.itemAnswer = itemAnswer;
		this.itemAnalysis = itemAnalysis;
		this.itemLevel = itemLevel;
		this.studentExerciceRecords = studentExerciceRecords;
		this.exerciceExams = exerciceExams;
		this.studentItemExercices = studentItemExercices;
	}

	// Property accessors
	@Id
	@Column(name = "item_no", unique = true, nullable = false, length = 50)
	public String getItemNo() {
		return this.itemNo;
	}

	public void setItemNo(String itemNo) {
		this.itemNo = itemNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cource_no", nullable = false)
	public Cource getCource() {
		return this.cource;
	}

	public void setCource(Cource cource) {
		this.cource = cource;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "exam_item_type_no", nullable = false)
	public ExamItemType getExamItemType() {
		return this.examItemType;
	}

	public void setExamItemType(ExamItemType examItemType) {
		this.examItemType = examItemType;
	}

	@Column(name = "item_description", length = 1024)
	public String getItemDescription() {
		return this.itemDescription;
	}

	public void setItemDescription(String itemDescription) {
		this.itemDescription = itemDescription;
	}

	@Column(name = "item_content", length = 1024)
	public String getItemContent() {
		return this.itemContent;
	}

	public void setItemContent(String itemContent) {
		this.itemContent = itemContent;
	}

	@Column(name = "item_answer", length = 1024)
	public String getItemAnswer() {
		return this.itemAnswer;
	}

	public void setItemAnswer(String itemAnswer) {
		this.itemAnswer = itemAnswer;
	}

	@Column(name = "item_analysis", length = 1024)
	public String getItemAnalysis() {
		return this.itemAnalysis;
	}

	public void setItemAnalysis(String itemAnalysis) {
		this.itemAnalysis = itemAnalysis;
	}

	@Column(name = "item_level", nullable = false)
	public Integer getItemLevel() {
		return this.itemLevel;
	}

	public void setItemLevel(Integer itemLevel) {
		this.itemLevel = itemLevel;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "exerciceItem")
	public Set<StudentExerciceRecord> getStudentExerciceRecords() {
		return this.studentExerciceRecords;
	}

	public void setStudentExerciceRecords(
			Set<StudentExerciceRecord> studentExerciceRecords) {
		this.studentExerciceRecords = studentExerciceRecords;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "exerciceItem")
	public Set<ExerciceExam> getExerciceExams() {
		return this.exerciceExams;
	}

	public void setExerciceExams(Set<ExerciceExam> exerciceExams) {
		this.exerciceExams = exerciceExams;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "exerciceItem")
	public Set<StudentItemExercice> getStudentItemExercices() {
		return this.studentItemExercices;
	}

	public void setStudentItemExercices(
			Set<StudentItemExercice> studentItemExercices) {
		this.studentItemExercices = studentItemExercices;
	}

}